﻿<Page
    x:Class="FlowSequencer.MetroSequencer.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FlowSequencer.MetroSequencer"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:converter="using:FlowSequencer.MetroSequencer.Converters"
    mc:Ignorable="d">

    <Window.Resources>
        <converter:ListIntToString x:Key="listIntToString" />

    </Window.Resources>

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

        
        <Grid.RowDefinitions>
                <RowDefinition Height="*" MinHeight="120px"/>
                <RowDefinition Height="50px"/>
                <RowDefinition Height="2*"/>
                <RowDefinition Height="50px"/>
            </Grid.RowDefinitions>

            <StackPanel Grid.Row="0">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition MinWidth="100px" />
                        <ColumnDefinition Width="3*"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Column="0">
                        <Label Margin="5,0,-5,0">Ilość zadań:</Label>
                        <TextBox Margin="15,2,10,2" x:Name="numberTasksTextBox"  Text="{Binding NumberOfTasks, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="numberTasksTextBox_TextChanged"/>
                        <Label Grid.Column="0" Margin="5,0,-5,0">Ilość maszyn:</Label>
                        <RadioButton Name="Machine2xRadioButton" GroupName="MachineNumberGroup" Checked="Machine2xRadioButton_Checked_1" IsChecked="{Binding IsTwoMachineMode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="17,0,10,0">2x maszyny</RadioButton>
                        <RadioButton Name="Machine3xRadioButton" GroupName="MachineNumberGroup" Checked="Machine3xRadioButton_Checked_1" Margin="16,0,10,0">3x maszyny</RadioButton>
                    </StackPanel>
                    <ListView Grid.Column="1" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible">
                        <GridView Name="processInputGrid" Margin="5" AutoGenerateColumns="False" ItemsSource="{Binding Lines, Mode=TwoWay, UpdateSourceTrigger=Explicit}">
                        <GridView.Columns>
                                <DataGridTemplateColumn>
                                    <DataGridTemplateColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Headers}">
                                                <ItemsControl.ItemsPanel>
                                                    <ItemsPanelTemplate>
                                                        <StackPanel Orientation="Horizontal"/>
                                                    </ItemsPanelTemplate>
                                                </ItemsControl.ItemsPanel>
                                                <ItemsControl.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Margin="2" Width="{Binding Width}" Foreground="{Binding Color}" Text="{Binding Data}"/>
                                                    </DataTemplate>
                                                </ItemsControl.ItemTemplate>
                                            </ItemsControl>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.HeaderTemplate>
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <ItemsControl ItemsSource="{Binding ColumnsData}">
                                                <ItemsControl.ItemsPanel>
                                                    <ItemsPanelTemplate>
                                                        <StackPanel Orientation="Horizontal"/>
                                                    </ItemsPanelTemplate>
                                                </ItemsControl.ItemsPanel>
                                                <ItemsControl.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBox Margin="2" Width="{Binding Width}" Text="{Binding Data}"/>
                                                    </DataTemplate>
                                                </ItemsControl.ItemTemplate>
                                            </ItemsControl>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>
                    </ListView>

                </Grid>
            </StackPanel>
            <Grid Grid.Row="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="25px"/>
                    <RowDefinition Height="25px"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" x:Name="OptimalSequencePart"  Text="{Binding OptimalSequencePart, Converter={StaticResource listIntToString}}" />

            </Grid>
            <ListView Grid.Row="2" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible">
                <Label Content="Wykres gantaa:"/>
                <Grid Name="ganttView">
                </Grid>
            </ListView>
            <Button Grid.Row="3" Name="startProcessingButton" Content="Oblicz" Click="startProcessingButton_Click_1"/>

    </Grid>
</Page>
